package ar.posti.framework.query.hibernate;

import java.util.TreeMap;

import org.hibernate.Query;

import ar.posti.framework.query.core.AbstractQueryAssembler;

public class HibernateQueryAssembler extends AbstractQueryAssembler<Query> {
	private HibernateQueryFactory queryFactory;

	public HibernateQueryAssembler(HibernateQueryFactory queryFactory) {
		this.queryFactory = queryFactory;
	}

	@Override
	public Query assemble() {
		TreeMap<String, Object> variables = new TreeMap<String, Object>();
		StringBuilder queryBuilder = new StringBuilder();
		
		super.doAssemble(queryBuilder, variables);
		Query query = queryFactory.createQuery(queryBuilder.toString(), variables);

		return query;
	}
}
